<?php

/**
 * 基础类
 * @author Chen Guo
 */

namespace Game\Controller;

use Think\Controller;

class CommonController extends Controller {

    public function _initialize() {
        // echo json_encode(getSignPackage());
        $arr = array(
            "title" => '奔跑吧，积分君，走起。',//转发标题
            "desc" => '这个游戏很刺激，没事进来赚点积分，捞点外快吧！',//转发内容
            "link" => U("Index/index",'',true,true),
            "imgUrl" => 'http://a.forcent.cn/ldh/app/Game/Static/images/share/share.jpg'
        );
        $this->assign('sharePackage', json_encode($arr));
        $this->assign('signPackage', json_encode(getSignPackage()));
    }

    /**
     * 获取客户端ip地址
     * @return type 
     */
    public function get_client_ip() {
        if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
            $ip = getenv("HTTP_CLIENT_IP");
        else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
            $ip = getenv("HTTP_X_FORWARDED_FOR");
        else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
            $ip = getenv("REMOTE_ADDR");
        else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
            $ip = $_SERVER['REMOTE_ADDR'];
        else
            $ip = FALSE;
        return $ip;
    }

    /**
     * 获取系统当前时间
     * @return type 
     */
    public function get_server_time() {
        return time();
    }
    


}

?>
